<?php

namespace Home\Model\Ajax;

class EditSp extends AbstractAjax
{
    // 修改擅长
    public function handle()
    {
        if (empty($this->uid)) {
            $ajax['status'] = 0;
            $ajax['content'] = "获取UID失败";
            return $ajax;
        } else {

            $u = D('User');
            $edit = I('request.edit', '0', 'intval');
            $specialty = I('request.specialty', '', 'trim');
            if ($edit || $specialty) {

                if (empty($specialty)) {
                    $ajax['status'] = 0;
                    $ajax['content'] = "特长不能为空！";
                    return $ajax;
                }
                $u->edit_specialty($this->uid, $specialty);
                $ajax['status'] = 1;
                $ajax['specialty'] = $specialty;
                $ajax['content'] = '修改成功！';
                D('Task')->exe_user_specialty($this->uid);
                return $ajax;
            } else {
                $us = $u->get_user_one($this->uid);
                $this->assign('specialty', $us['specialty']);
                $html = $this->fetch('ajax_edit_sp');
                $ajax['status'] = 1;
                $ajax['content'] = $html;
                return $ajax;
            }
        }
    }

}